package com.qa.dom.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.qa.dom.entity.Param;
import com.qa.dom.service.IParamService;
import com.qa.dom.util.JsonResult;
import com.qa.dom.util.baseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  参数表控制器
 * </p>
 *
 * @author z77z
 * @since 2017-12-25
 */
@Api(description = "参数表控制器",value = "参数表控制器",tags = {"PARAM"})
@RestController
@RequestMapping("/param")
public class ParamController extends baseAction {

    @Resource
    private IParamService iParamService;

    @GetMapping("/queryParam")
    public JsonResult queryParam(@ApiParam("参数名") @RequestParam("para") String para){
        EntityWrapper<Param> paras= new EntityWrapper<>();
        //年级
        paras.eq("paramalias",para);
        List<Param> list1= iParamService.selectList(paras);
        if(list1.size()== 0){
            return renderError("该年级不存在");
        }
        return renderSuccess(1,"请求成功",list1.size(),list1);
    }

    /**
     * 获取课程
     * @param param
     * @return
     */
    @PostMapping("/queryCourse")
    @ApiOperation(value = "获取课程",notes = "获取课程",httpMethod = "POST")
    public JsonResult queryCourse(@RequestBody  Param param){
        EntityWrapper<Param> paras= new EntityWrapper<>();
        System.out.println("<<<<<"+param);
        List<Param> list1= iParamService.queryCourse(param);
        if (list1.size() == 0){
            return renderError("获取可能");

        }
        return renderSuccess(1,"请求成功",list1.size(),list1);
    }

}
